package top.hzy520.admin.carousel.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.hzy520.admin.carousel.dao.ConstsSiteCarouselMapper;
import top.hzy520.admin.carousel.entity.ConstsSiteCarousel;

import java.util.Date;
import java.util.List;

/**
 * @Author: HouZeYu
 * @Description:
 * @Date: Created in 9:28 2019/6/5
 */
@Service
public class CarouselServiceImpl implements CarouselService {

    @Autowired
    private ConstsSiteCarouselMapper carouselMapper;

    @Override
    public List<ConstsSiteCarousel> constsSiteCarouselPagination(int offset, int limit) {
        return carouselMapper.selectCarouselPagination(offset,limit);
    }

    @Override
    public int constsSiteCarouselPaginationCount() {
        return carouselMapper.constsSiteCarouselPaginationCount();
    }

    @Override
    public int carouselChangeStatus(ConstsSiteCarousel carousel) {
        return carouselMapper.updateByPrimaryKeySelective(carousel);
    }

    @Override
    public void carouselRemove(List<Integer> idList) {
        carouselMapper.carouselRemove(idList);
    }

    @Override
    public int carouselAddPost(ConstsSiteCarousel carousel) {
        carousel.setCreateTime(new Date());
        return carouselMapper.insertSelective(carousel);
    }

    @Override
    public ConstsSiteCarousel findCarouselById(Integer id) {
        return carouselMapper.selectByPrimaryKey(id);
    }

    @Override
    public int carouselEditPost(ConstsSiteCarousel carousel) {
        return carouselMapper.updateByPrimaryKeySelective(carousel);
    }
}
